class Scope:
    allow_endpoint = {}
    forbidden_endpoint = {}

    def __add__(self, other):
        self.allow_endpoint = self.allow_endpoint | other.allow_api
        self.allow_module = self.allow_module | other.allow_module
        self.forbidden_endpoint = self.forbidden_endpoint | other.forbidden
        return self


class UserScope(Scope):
    forbidden_endpoint = {}
    allow_endpoint = {}
    allow_blueprint = {'web'}


class AdminScope(Scope):
    forbidden_endpoint = {}
    allow_endpoint = {}
    allow_blueprint = {'admin'}


def inscope(scope, endpoint):
    scope = globals()[scope]()
    if endpoint in scope.forbidden_endpoint:
        return False
    blueprint_name = endpoint.split('.')[0]
    if blueprint_name in scope.allow_blueprint:
        return True
    if endpoint in scope.allow_endpoint:
        return True
    return False
